const modulesFiles = require.context("./", true, /\.js$/);

const modules = modulesFiles.keys().reduce((modules, modulePath) => {
  // set './app.js' => 'app'
  const moduleName = modulePath
    .replace(/^\.\/(.*)\.\w+$/, "$1")
    .replace("/index", "");
  const value = modulesFiles(modulePath);
  if (value.default) {
    modules[moduleName] = value.default;
  }
  return modules;
}, {});
let materalList = [];
let materalJson = {};
for (const modulesValue in modules) {
  const objValue = modules[modulesValue];
  if (objValue) {
    materalList.push(objValue.CONFIG);
    materalJson[modulesValue] = objValue.JSON;
  }
}
// 所有接口
export default {
  list: materalList,
  json: materalJson,
};
